/**
 * @file
 * @author dousha 
 * @date 2020/11/28.
 */

#ifndef CRYPTSTICK_OLED_H
#define CRYPTSTICK_OLED_H

#include <stm32f1xx_hal.h>

#define OLED_WRITE_ADDR 0x78u

#define OLED_SET_CONTRAST         0x81u
#define OLED_SET_ENTIRE_ON        0xa4u
#define OLED_SET_NORM_INV         0xa6u
#define OLED_SET_DISP             0xaeu
#define OLED_SET_MEM_ADDR         0x20u
#define OLED_SET_COL_ADDR         0x21u
#define OLED_SET_PAGE_ADDR        0x22u
#define OLED_SET_DISP_START_LINE  0x40u
#define OLED_SET_SEG_REMAP        0xa0u
#define OLED_SET_MUX_RATIO        0xa8u
#define OLED_SET_COM_OUT_DIR      0xc0u
#define OLED_SET_DISP_OFFSET      0xd3u
#define OLED_SET_COM_PIN_CFG      0xdau
#define OLED_SET_DISP_CLK_DIV     0xd5u
#define OLED_SET_PRECHARGE        0xd9u
#define OLED_SET_VCOM_DESEL       0xdbu
#define OLED_SET_CHARGE_PUMP      0x8du
#define OLED_SET_COM_SCAN_DEC     0xc8u
#define OLED_SET_NO_SCROLL        0x2eu
#define OLED_SET_DONE_AND_ENABLE  0xafu

extern void oled_init(I2C_HandleTypeDef *);

extern void oled_write_command_byte(uint8_t);

extern void oled_write_data_byte(uint8_t);

extern void oled_update_screen();

extern void oled_clear_screen();

extern void oled_draw_pixel(uint8_t, uint8_t);

extern void oled_draw_horizontal_line(uint8_t, uint8_t, uint8_t);

extern void oled_draw_vertical_line(uint8_t, uint8_t, uint8_t);

extern void oled_draw_line(uint8_t, uint8_t, uint8_t, uint8_t);

extern void oled_draw_box(uint8_t, uint8_t, uint8_t, uint8_t);

extern void oled_write_char(uint8_t, uint8_t, char);

extern void oled_move_caret(uint8_t, uint8_t);

extern void oled_write_string(const char *);

extern void oled_clear_row(uint8_t);

extern void oled_write_length_string(const char *, uint8_t);

extern void oled_write_bytes(const uint8_t *, uint8_t);

#endif //CRYPTSTICK_OLED_H
